/**
 * 
 */
package homework6;

import tester.Tester;

/**
 * @author Nican
 * 
 */
public class Examples {

	SpreadSheet s = new SpreadSheet();

	public void testSpreadsheet(Tester t) {

		s.editContents("a10", new Num(5));
		s.editContents("b10", new Num(3));
		s.editContents("c10", new Plus(new CellRef("a10"), new CellRef("b10")));
		t.checkExpect(8, s.lookupValue("c10"));

	}

	public void testSpreadsheet2(Tester t) {

		s.editContents("a10", new Num(5));
		s.editContents("b10", new Num(3));
		s.editContents("c10", new Plus(new CellRef("a10"), new CellRef("b10")));
		s.editContents("a10", new Num(9));
		t.checkExpect(12, s.lookupValue("c10"));

	}
	
	public void testSpreadsheet3(Tester t) {

		s.editContents("a10", new Num(5));
		s.editContents("b10", new Num(5));
		s.editContents("c10", new Plus(new CellRef("a10"), new CellRef("b10")));
		
		s.editContents("a20", new Num(6));
		s.editContents("b20", new Num(6));
		s.editContents("c20", new Plus(new CellRef("a20"), new CellRef("b20")));
		
		s.editContents("d10", new Plus(new CellRef("c10"), new CellRef("c20")));
		t.checkExpect(22, s.lookupValue("d10"));

	}
	
	public void testSpreadsheet4(Tester t) {

		s.editContents("a10", new Num(5));
		s.editContents("b10", new Num(5));
		s.editContents("c10", new Plus(new CellRef("c20"), new CellRef("b10")));
		
		s.editContents("a20", new Num(6));
		s.editContents("b20", new Num(6));
		s.editContents("c20", new Plus(new CellRef("c10"), new CellRef("b20")));
		
		s.editContents("d10", new Plus(new CellRef("c10"), new CellRef("c20")));
		t.checkExpect(22, s.lookupValue("d10"));

	}

	public static void main(String[] args) {
		Tester.run(new Examples());
	}
}
